<template>
  <h1>一个人的信息</h1>
  <h2>姓名：{{ person.name }}</h2>
  <h2>年龄：{{ person.age }}</h2>
  <h3>工种：{{ person.job.type }}</h3>
  <h3>工资：{{ person.job.salary }}</h3>
  <h3>测试c：{{ person.job.a.b.c }}</h3>
  <div v-for="(h, index) in person.hobbies" :key="index">{{ h }}</div>
  <button @click="changeInfo">修改人的信息</button>
</template>

<script>
import { reactive } from "vue";
export default {
  name: "App",
  setup() {
    /* let name = ref("张三"); // RefImpl
    let age = ref(18);
    let job = reactive({
      type: "前端工程师",
      salary: "30k",
      a: {
        b: {
          c: 666,
        },
      },
    });
    let hobbies = reactive(["唱", "跳", "RAP", "篮球"]); */
    // let number = reactive(666);// lue cannot be made reactive: 666

    let person = reactive({
      name: "张三",
      age: 18,
      job: {
        type: "前端开发工程师",
        salary: "30k",
        a: {
          b: {
            c: 666,
          },
        },
      },
      hobbies: ["唱", "跳", "RAP", "篮球"],
    });

    function changeInfo() {
      console.log(person.job);
      person.name = "李四";
      person.age = 19;
      person.job.salary = "60k";
      person.job.a.b.c = 999;
      person.hobbies[0] = "睡觉";
    }

    return {
      /* name,
      age,
      job,
      hobbies, */
      person,
      changeInfo,
    };
  },
};
</script>
